package org.Yiran.timetale_re.datagen;

import net.minecraft.data.PackOutput;
import net.minecraft.data.recipes.FinishedRecipe;
import net.minecraft.data.recipes.RecipeProvider;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraftforge.common.crafting.conditions.IConditionBuilder;
import org.Yiran.timetale_re.Timetale_re;
import org.Yiran.timetale_re.item.ItemsRegister;
import org.Yiran.timetale_re.recipe.AnvilForgeRecipe;
import org.jetbrains.annotations.NotNull;

import java.util.function.Consumer;

/**
 * 模组铁砧锻造配方数据生成器
 * 用于生成模组中自定义的铁砧锻造配方
 */
public class ModAnvilForgeRecipeProvider extends RecipeProvider implements IConditionBuilder {
    
    /**
     * 构造函数
     * 
     * @param output 数据包输出路径
     */
    public ModAnvilForgeRecipeProvider(PackOutput output) {
        super(output);
    }

    /**
     * 构建所有锻造配方
     * 
     * @param consumer 配方消费者
     */
    @Override
    protected void buildRecipes(@NotNull Consumer<FinishedRecipe> consumer) {
        registerAnvilForgeRecipes(consumer);
    }
    
    /**
     * 注册铁砧锻造配方
     * 
     * @param consumer 配方消费者
     */
    private void registerAnvilForgeRecipes(@NotNull Consumer<FinishedRecipe> consumer) {
        buildIronIngotToIronSheetRecipe(consumer);
        // 在这里可以添加更多配方的注册
    }
    
    /**
     * 构建铁锭到铁板的锻造配方
     * 
     * @param consumer 配方消费者
     */
    private void buildIronIngotToIronSheetRecipe(@NotNull Consumer<FinishedRecipe> consumer) {
        // 铁锭锻造为铁板的配方
        // 需要铁锤(等级2)或更高等级的锤子
        AnvilForgeRecipe.Builder.create(
                "iron_ingot_to_iron_sheet",
                new ItemStack(ItemsRegister.IRON_SHEET.get()),
                Ingredient.of(Items.IRON_INGOT),
                1,
                2,
                3000 // 3秒锻造时间(以毫秒为单位)
        ).save(consumer, Timetale_re.MODID + ":iron_ingot_to_iron_sheet");
    }
}